******************************************************************************** 

* 						MEASURING TRADE OFF, Tables 5 and 10

********************************************************************************

****** Gender, Table 5

clear
use "${data}cleaned_data_y3.dta"

do "${blocks}construct_new_variables"

gen domestic=1 if DomicileCategory=="Home"
replace domestic=0 if domestic==.

tempname statistics
tempfile stats
postfile `statistics' ///
    str100 statistic p_g da_h lower_bound da_g p_h upper_bound using "`stats'", replace
	
	ttest  ns_std_perc_y1 if EEMP==0, by(type)
	local p_g=r(mu_2)
	local da_h=r(mu_1)
	local lower_bound=r(mu_2)-r(mu_1)
	
	ttest  ns_std_perc_y1  if EEMP==0, by(type_rev)
	local p_h=r(mu_2)
	local da_g=r(mu_1)
	local upper_bound=r(mu_1)-r(mu_2)

	post `statistics' ("\quad non-MI subjects")  (.) (.) (.) (.) (.) (.)
	
	
	post `statistics' ("\quad \quad Mean ") (`p_g') (`da_h') (`lower_bound')   (`da_g') (`p_h') (`upper_bound') 

	ci means ns_std_perc_y1 if EEMP==0 & type==2
	local p_g=r(se)

	ci means ns_std_perc_y1 if EEMP==0 & type==1
	local da_h=r(se)

	ttest  ns_std_perc_y1 if EEMP==0, by(type)
	local lower_bound=r(se)	

	
	ci means ns_std_perc_y1 if EEMP==0 & type_rev==1
	local da_g=r(se)

	ci means ns_std_perc_y1 if EEMP==0 & type_rev==2
	local p_h=r(se)

	ttest  ns_std_perc_y1 if EEMP==0, by(type_rev)
	local upper_bound=r(se)	

	post `statistics' ("\quad \quad SE")  (`p_g') (`da_h') (`lower_bound')   (`da_g') (`p_h') (`upper_bound') 
	

	ttest  ns_std_perc_y1 if EEMP==1, by(type)
	local p_g=r(mu_2)
	local da_h=r(mu_1)
	local lower_bound=r(mu_2)-r(mu_1)
	
	ttest  ns_std_perc_y1  if EEMP==1, by(type_rev)
	local p_h=r(mu_2)
	local da_g=r(mu_1)
	local upper_bound=r(mu_1)-r(mu_2)

	post `statistics' ("\quad MI subjects")  (.) (.) (.) (.) (.) (.)
	

	post `statistics' ("\quad \quad Mean")	(`p_g') (`da_h') (`lower_bound')   (`da_g') (`p_h') (`upper_bound') 
	
	
	
	ci means ns_std_perc_y1 if EEMP==1 & type==1
	local p_g=r(se)

	ci means ns_std_perc_y1 if EEMP==1 & type==2
	local da_h=r(se)

	ttest  ns_std_perc_y1 if EEMP==1, by(type)
	local lower_bound=r(se)	

	
	ci means ns_std_perc_y1 if EEMP==1 & type_rev==1
	local da_g=r(se)

	ci means ns_std_perc_y1 if EEMP==1 & type_rev==2
	local p_h=r(se)

	ttest  ns_std_perc_y1 if EEMP==1, by(type_rev)
	local upper_bound=r(se)	

	post `statistics' ("\quad \quad SE")  (`p_g') (`da_h') (`lower_bound')   (`da_g') (`p_h') (`upper_bound') 


postclose `statistics'	
use `stats', clear
format p_g %9.2fc
format p_h %9.2fc
format da_g %9.2fc
format da_h %9.2fc
format lower_bound %9.2fc
format upper_bound %9.2fc
	
listtab * using "${tables}measuring_tradeoff_gender_test.tex", ///
    rstyle(tabular) replace ///
    head("\begin{tabular}{@{\extracolsep{2pt}} l c c c c c c  D{.}{.}{-3} D{.}{.}{-3}}" ///
    "\toprule" ///
	   " & \multicolumn{1}{c}{Pooled} & \multicolumn{1}{c}{DA } & \multicolumn{1}{c}{Lower} & \multicolumn{1}{c}{DA}  & \multicolumn{1}{c}{Pooled} & \multicolumn{1}{c}{Upper} \\" "& \multicolumn{1}{c}{males (\textit{g})} & \multicolumn{1}{c}{females (\textit{h})} & \multicolumn{1}{c}{bound of $\beta$} & \multicolumn{1}{c}{males (\textit{g})}  & \multicolumn{1}{c}{females (\textit{h})} & \multicolumn{1}{c}{bound of $\beta$} \\ \midrule" "& (1) & (2) & (3) & (4) & (5) & (6) \\ \midrule"  ) ///
	   ///
    foot("\bottomrule" "\end{tabular}")
	
	
****** School type, Table 10

clear
use "${data}cleaned_data_y3.dta"

do "${blocks}construct_new_variables"

gen domestic=1 if DomicileCategory=="Home"
replace domestic=0 if domestic==.

tempname school
tempfile stats
postfile `school' ///
    str100 statistic p_g da_h lower_bound da_g p_h upper_bound using "`stats'", replace
	
	
	ttest  ns_std_perc_y1 if EEMP==0, by(type_school)
	local p_g=r(mu_2)
	local da_h=r(mu_1)
	local lower_bound=r(mu_2)-r(mu_1)
	
	ttest  ns_std_perc_y1  if EEMP==0, by(type_school_rev)
	local p_h=r(mu_2)
	local da_g=r(mu_1)
	local upper_bound=r(mu_1)-r(mu_2)

	post `school' ("\quad non-MI subjects")  (.) (.) (.) (.) (.) (.)

	post `school' ("\quad \quad Mean")  (`p_g') (`da_h') (`lower_bound')   (`da_g') (`p_h') (`upper_bound') 
	
	
	ci means ns_std_perc_y1 if type_school==2 & EEMP==0
	local p_g=r(se)

	ci means ns_std_perc_y1 if type_school==1 & EEMP==0
	local da_h=r(se)

	ttest  ns_std_perc_y1 if EEMP==0, by(type_school)
	local lower_bound=r(se)	

	
	ci means ns_std_perc_y1 if type_school_rev==1 & EEMP==0
	local da_g=r(se)

	ci means ns_std_perc_y1 if type_school_rev==2 & EEMP==0
	local p_h=r(se)

	ttest  ns_std_perc_y1 if EEMP==0, by(type_school_rev)
	local upper_bound=r(se)	

	post `school' ("\quad \quad SE")  (`p_g') (`da_h') (`lower_bound')   (`da_g') (`p_h') (`upper_bound') 

	ttest  ns_std_perc_y1 if EEMP==1, by(type_school)
	local p_g=r(mu_2)
	local da_h=r(mu_1)
	local lower_bound=r(mu_2)-r(mu_1)
	
	ttest  ns_std_perc_y1  if EEMP==1, by(type_school_rev)
	local p_h=r(mu_2)
	local da_g=r(mu_1)
	local upper_bound=r(mu_1)-r(mu_2)

	post `school' ("\quad MI subjects")  (.) (.) (.) (.) (.) (.)

	post `school' ("\quad \quad Mean")  (`p_g') (`da_h') (`lower_bound')   (`da_g') (`p_h') (`upper_bound') 
	
	
	ci means ns_std_perc_y1 if type_school==2 & EEMP==1
	local p_g=r(se)

	ci means ns_std_perc_y1 if type_school==1 & EEMP==1
	local da_h=r(se)

	ttest  ns_std_perc_y1 if EEMP==1, by(type_school)
	local lower_bound=r(se)	

	
	ci means ns_std_perc_y1 if type_school_rev==1 & EEMP==1
	local da_g=r(se)

	ci means ns_std_perc_y1 if type_school_rev==2 & EEMP==1
	local p_h=r(se)

	ttest  ns_std_perc_y1 if EEMP==0, by(type_school_rev)
	local upper_bound=r(se)	

	post `school' ("\quad \quad SE")  (`p_g') (`da_h') (`lower_bound')   (`da_g') (`p_h') (`upper_bound') 

	
postclose `school'	
use `stats', clear
format p_g %9.2fc
format p_h %9.2fc
format da_g %9.2fc
format da_h %9.2fc
format lower_bound %9.2fc
format upper_bound %9.2fc
	
listtab * using "${tables}measuring_tradeoff_school_test.tex", ///
    rstyle(tabular) replace ///
    head("\begin{tabular}{@{\extracolsep{2pt}} l c c c c c c  D{.}{.}{-3} D{.}{.}{-3}}" ///
    "\toprule" ///
	   " & \multicolumn{1}{c}{Pooled} & \multicolumn{1}{c}{DA } & \multicolumn{1}{c}{Lower} & \multicolumn{1}{c}{DA}  & \multicolumn{1}{c}{Pooled} & \multicolumn{1}{c}{Upper} \\" "& \multicolumn{1}{c}{private (\textit{g})} & \multicolumn{1}{c}{state (\textit{h})} & \multicolumn{1}{c}{bound of $\beta$} & \multicolumn{1}{c}{private (\textit{g})}  & \multicolumn{1}{c}{state (\textit{h})} & \multicolumn{1}{c}{bound of $\beta$} \\ \midrule" "& (1) & (2) & (3) & (4) & (5) & (6) \\ \midrule"  ) ///
	   ///
    foot("\bottomrule" "\end{tabular}")	
	